<?php

namespace MLM\Model\Generic;

use Zend\Mvc\Controller\AbstractActionController;

class Controller extends AbstractActionController {

    protected $_db;
    protected $_config;

    public function onDispatch(\Zend\Mvc\MvcEvent $e) {

        $this->_config = $this->getServiceLocator()->get('Config');

        /* create db adapter untuk neuron / crm */
        $config = $this->_config['databases']['app']['mlm'];
        $config['dsn'] = 'mysql:dbname=' . $config['schema'] . ';host=' . $config['host'];
        $this->_db = new \Zend\Db\Adapter\Adapter($config);

        return parent::onDispatch($e);
    }

    public function getConfig() {

        return $this->_config;
    }

    public function getDb() {

        return $this->_db;
    }

}
